package cn.lf.controller;


import cn.lf.dto.carouseimg.*;
import cn.lf.service.ICarouselImgService;
import cn.lf.utils.ResponseModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author guoyy
 * @since 2024-04-18
 */
@RestController
@RequestMapping("/carousel-img")
@Api(tags = "轮播图相关接口")
public class CarouselImgController {

    @Autowired
    private ICarouselImgService carouselImgService;

    @GetMapping("getAllCarouselImg")
    @ApiOperation("获取所有的轮播图 分页")
    public ResponseModel<IPage<AllCiRepDTO>> getAllCarouselImgPage(AllCiReqDTO params){

        IPage<AllCiRepDTO> result = carouselImgService.getAllCarouselImgPage(params);

        return ResponseModel.buildSuccessResult(result);
    }

    @PostMapping("saveCarouselImg")
    @ApiOperation("新增或保存轮播图")
    public ResponseModel saveCarouselImg(@RequestBody CiSaveReqDTO ciSaveReqDTO){

        carouselImgService.saveCarouselImg(ciSaveReqDTO);

         return ResponseModel.buildSuccessResult();
    }

    @GetMapping("delCarouselImg")
    @ApiOperation("删除轮播图")
    public ResponseModel delCarouselImg(@RequestParam String imgId){

        carouselImgService.delCarouselImg(imgId);

        return ResponseModel.buildSuccessResult();
    }

    @PostMapping("setCarouselImgStatus")
    @ApiOperation("设置轮播图状态")
    public ResponseModel setCarouselImgStatus(@RequestBody CiStatusSetReqDTO ciStatusSetReqDTO){

        carouselImgService.setCarouselImgStatus(ciStatusSetReqDTO);

        return ResponseModel.buildSuccessResult();
    }

    @GetMapping("getCarouselImgById")
    @ApiOperation("根据id获取轮播图信息")
    public ResponseModel<SingleCiInfoRepDTO> getCarouselImgById(@RequestParam String imgId){

        SingleCiInfoRepDTO result = carouselImgService.getCarouselImgById(imgId);

        return ResponseModel.buildSuccessResult(result);
    }

}
